import * as api from '../api'
export default(state,action)=>{
    state = state || {data:[]};
    switch(action.type){
        case 'rank_init':
            return {data:action.data}
        default:
            return state;
    }
}
export const rank = () => (dispatch) => {
    fetch(api.TOP_LIST).then(response=>response.json()).then(result=>{
        // console.log(result)
        if(result.errno===0){
            dispatch({type:'rank_init',data:result.data})
        }
    })
}